#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int T,n,m,L,V,d[N],v[N],a[N],pos[N];
int tr[N],fst[N],lst[N],qzh[N];
int st[N],ed[N];
vector<int> aaa[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        memset(pos,0,sizeof(pos));
        
        memset(st,0,sizeof(st));
        memset(ed,0,sizeof(ed));
        memset(tr,0,sizeof(tr));
        memset(qzh,0,sizeof(qzh));
        memset(fst,0,sizeof(fst));
        memset(lst,0,sizeof(lst));
        memset(aaa,0,sizeof(aaa));
        scanf("%d%d%d%d",&n,&m,&L,&V);
        int ans1=0,ans2=m;
        for(int i=1;i<=n;++i){
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
            if(v[i]>V){
                st[i]=d[i];
                if(a[i]>=0) ed[i]=L;
                else{
                    float t=(V-v[i])/(float)a[i];
                    ed[i]=floor(v[i]*t+0.5*a[i]*t*t+d[i]-0.001);
                }
            }
            if(v[i]<V){
                if(a[i]<=0);
                else{
                    float t=(V-v[i])/(float)a[i];
                    st[i]=ceil(v[i]*t+0.5*a[i]*t*t+d[i]+0.001);
                    ed[i]=L;
                }
            }
        }
        for(int i=1;i<=m;++i){
            scanf("%d",&pos[i]);
            //if(!road[pos[i]]) ans2++;
        }
        sort(pos+1,pos+m+1);
        for(int i=1;i<=n;++i){
            fst[i]=lower_bound(pos+1,pos+m+1,st[i])-pos;
            lst[i]=upper_bound(pos+1,pos+m+1,ed[i])-pos-1;
            //cout<<fst<<" "<<lst<<endl;
            if(fst[i]<=lst[i]&&fst[i]!=m+1&&lst[i]!=0){
                ans1++;
                tr[fst[i]]++;tr[lst[i]+1]--;
                for(int j=fst[i];j<=lst[i];++j){
                    aaa[j].push_back(i);
                }
            }
        }
        bool flag=true;
        while(flag){
            ans2--;
            int mx=0,mxpos;
            for(int i=1;i<=m;++i){
                qzh[i]=qzh[i-1]+tr[i];
                if(qzh[i]>mx){
                    mx=qzh[i];
                    mxpos=i;
                }
            }
            for(int i=0;i<aaa[mxpos].size();++i){
                tr[fst[aaa[mxpos][i]]]--;
                tr[lst[aaa[mxpos][i]]+1]++;
            }
                
            if(mx==0) flag=false;
        }
        printf("%d %d\n",ans1,ans2);

    }
        
    //for(int i=1;i<=n;++i) cout<<st[i]<<" "<<ed[i]<<endl;
    return 0;
}